#!usr/bin/env python
# -*- coding:utf-8 -*-
# user nanme: Mr.zhang
# data time : 2022/11/15   3:35 下午
# project   : conf_devices.py
# IDE       : PyCharm
# email     :17600960626@163.com

import logging
import subprocess
import sys


class devices:

    def devlists(self):
        #连接的设备列表
        device_str = subprocess.getoutput('adb devices')
        device_list = []
        m = device_str.strip().split('\n')
        for line in m[1:]:
            if 'List' not in line:
                device_list.append(line.split('\t')[0])
        # print('已连接设备数量%s台\n连接设备devicesID列表:%s'%(len(device_list),device_list))
        try:
            if len(device_list) == 0:
                logging.warning("设备为空，请连接设备")
                pass
            else:
                return device_list
        except:
            logging.error('设备异常')


